export default function createProxy(env) {
  const { VITE_APP_PROXY, VITE_APP_API_DOMAIN } = env
  let proxy = {}
  if (VITE_APP_PROXY) {
    let reg = new RegExp(`^${VITE_APP_PROXY}`)
    proxy = {
      [VITE_APP_PROXY]: {
        target: VITE_APP_API_DOMAIN,
        changeOrigin: true,
        rewrite: (p) => p.replace(reg, ''),
      },
    }
  }
  return proxy
}
